#include <iostream>
#include <stdio.h>
#include <cstring>
#include <climits>

#define maxn 10005
#define maxm 105
using namespace std;
int mod = 1000000007;
int dp[maxn][maxm], sum[maxn][maxm];
int n, m, ans;

int main() {
//   freopen("2017080421.in ","r",stdin);
    int T;
    cin >> T;
    for (int cas = 1; cas <= T; cas++) {
        cin >> n >> m;  //n城市数量,m核电站种类数
        for (int i = 0; i <= n + 1; i++)
            for (int j = 0; j <= m + 1; j++)
                dp[i][j] = sum[i][j] = 0;
        dp[0][0] = 1;
        for (int i = 0; i <= m; i++)
            sum[0][i] = 1;
        for (int i = 1; i <= n; i++) {
            dp[i][0] = dp[i - 1][0];
            //cout<<"dp[i][0]:"<<dp[i][0]<<endl;
            for (int j = 0; j <= m; j++)
                dp[i][j] = (dp[i][j] + dp[i - 1][j + 1]) % mod;
            for (int j = 1; j <= m; j++) {
                if ( i - j - 1 >= 0 ) dp[i][j] = (dp[i][j] + sum[i - j - 1][j]) % mod;
                else dp[i][j] = (dp[i][j] + 1) % mod;
            }
            sum[i][0] = dp[i][0];
            for (int j = 1; j <= m; j++) {
                sum[i][j] = sum[i][j - 1];
                sum[i][j] = (sum[i][j] + dp[i][j]) % mod;
            }
        }
        //ans=0;
        //for(int i=0;i<=m;i++) ans=(ans+dp[n][i])%mod;
        //cout<<"Case "<<cas<<": "<<ans<<endl;
        cout << "Case " << cas << ": " << sum[n][m] << endl;
    }
    return 0;
}